package com.sgb.member.ui.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.sgb.member.BR;
import com.sgb.member.MemberConfig;
import com.sgb.member.R;
import com.sgb.member.databinding.ItemClientDynamicStateBinding;
import com.sgb.member.entity.ClientDynamicStateBean;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;
import com.swgk.core.util.DateUtils;
import com.swgk.core.util.MToast;
import com.swgk.core.util.StringUtil;

import java.util.List;

public class ClientDynamicStateAdapter extends BaseRecycleAdapter<ClientDynamicStateBean> {

    public ClientDynamicStateAdapter(Context context, List<ClientDynamicStateBean> datas) {
        super(context, R.layout.item_client_dynamic_state, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, final ClientDynamicStateBean entity) {
        holder.setBinding(BR.viewModel, entity);
        ItemClientDynamicStateBinding viewDataBinding = (ItemClientDynamicStateBinding) holder.getmBinding();
        viewDataBinding.tvCreateTime.setText(DateUtils.timestampTo13Date3(Long.parseLong(entity.getCreateTime())));
        viewDataBinding.tvCompanyName.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!TextUtils.isEmpty(entity.getCompanyNo())) {
                    MemberConfig.getInstance().startWebsiteInfo(context, entity.getCompanyNo(), 1);
                } else {
                    MToast.showToast(context, "店铺No为空");
                }
            }
        });
    }
}
